Skip to content

Feature/sidebar focus#1719

Open
Dipanshusinghh wants to merge 2 commits into
elementary:masterfrom
Dipanshusinghh:feature/sidebar-focus
Open

Feature/sidebar focus#1719
Dipanshusinghh wants to merge 2 commits into
elementary:masterfrom
Dipanshusinghh:feature/sidebar-focus

Conversation

@Dipanshusinghh
Copy link
Copy Markdown
Contributor

Summary

This PR fixes the keyboard accessibility issue where the project sidebar could not be focused via keyboard navigation.

Changes Made

  • Made Code.Sidebar focusable by setting can_focus = true.
  • Added ACTION_FOCUS_SIDEBAR (action-focus-sidebar) to MainWindow.
  • Bound <Control><Alt>Left to focus the sidebar directly (and opens it automatically if it is currently hidden).

Fixes #1711

Allows users to move keyboard focus directly to the projects sidebar using <Control><Alt>Left, improving accessibility and full keyboard navigation.
Copy link
Copy Markdown
Collaborator

@jeremypw jeremypw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this does not seem to work yet - focus remains with the document for me. Not sure why yet, but it does work if you focus the choose_project_button instead. So its something to do with making sure the treeview within the SourceList gets (and retains) the final focus.

Also may need a matching hotkey to return focus to the document but that can be addressed later.

I notice that if you do focus the choose_project_button then you can reach other widgets in the headerbar by using the standard Tab and <Shift>Tab keys. But not the actionbar.

Comment thread src/Widgets/Sidebar.vala Outdated
construct {
orientation = Gtk.Orientation.VERTICAL;
get_style_context ().add_class (Gtk.STYLE_CLASS_SIDEBAR);
can_focus = true;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure this right - Sidebar is a container (Grid) which cannot have keyboard focus itself

@Dipanshusinghh Dipanshusinghh force-pushed the feature/sidebar-focus branch from 0916dbb to 9f37b0e Compare May 17, 2026 16:47
@Dipanshusinghh
Copy link
Copy Markdown
Contributor Author

Dipanshusinghh commented May 17, 2026

@jeremypw Thanks for the detailed review and for pointing out the root cause!

You are completely right. Sidebar is a Gtk.Grid container and shouldn't have can_focus = true. The issue with the focus not reaching the actual treeview happens because calling grab_focus() on the SourceList (which is a Gtk.ScrolledWindow) doesn't automatically pass the focus down to its child Gtk.TreeView

I have addressed the requested changes:-.

  1. Removed can_focus = true; from Code.Sidebar
  2. Overridden grab_focus() in Code.Widgets.SourceList to explicitly call tree.grab_focus(), ensuring the underlying Gtk.TreeView gets and retains the final keyboard focus

Regarding the shortcut to return focus to the document and the Actionbar tab navigation, I agree that those can be addressed in a separate follow-up PR as enhancements

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sidebar difficult to focus using keyboard

2 participants